﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Engine.Components.Workers
{
    public class DirectoryScanner:Abstract.WorkerBase
    {
        #region FACTORY
        private DirectoryScanner(HunterPluginSDK.Interface.IProgressHandler ph)
        {
            this.ProgressHandler = ph;
        }
        static public Engine.Components.Interface.IWorker CreateWorker(HunterPluginSDK.Interface.IProgressHandler ph)
        {
            return new DirectoryScanner(ph);
        }
        #endregion


        protected override void DoMyJob(object o)
        {
            string path = o as string;
            Engine.IO.FileSystemEnumerator fe = new Engine.IO.FileSystemEnumerator(path, "*.*", true);
            foreach (FileInfo fi in fe.Matches())
            {
                try
                {
                    this.OnProduced(fi);
                }
                catch(Exception)
                {
                    
                }
            }
        }


    }
}
